package com.yang.utils;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import com.yang.domain.Captcha;

/**
 * @Author: 不是菜鸡爱编程
 * @Date: 2024/02/17/23:08
 * @Description:
 */
public class CommonUtils {
    /**
     * 生成验证码
     *
     * @return {@link Captcha}
     */
    public static Captcha generateCaptcha(){
        String captcha= RandomUtil.randomString (6);
        String uuid = IdUtil.randomUUID();
        return new Captcha(uuid,captcha, DateUtil.now(),3,1);
    }
    /**
     * 生成验证码
     *
     * @param keepTime 保持时间
     * @return {@link Captcha}
     */
    public static Captcha generateCaptcha(Integer keepTime){
        String captcha= RandomUtil.randomString (6);
        String uuid = IdUtil.randomUUID();
        return new Captcha(uuid,captcha, DateUtil.now(),keepTime,1);
    }
}
